package view
{
	
	import event.GotoClickButtonEvent;
	
	import flash.events.MouseEvent;
	
	import mx.collections.ArrayCollection;
	
	import spark.components.Button;
	import spark.components.List;
	import spark.components.supportClasses.SkinnableComponent;
	
	[Event(name="gotoClickButton", type="event.GotoClickButtonEvent")]
	public class ChatHistory extends SkinnableComponent
	{
		[SkinPart] public var chatButton:Button;
		[SkinPart] public var historyList:List;
		
		[Bindable] public var chatHistory:ArrayCollection;
		
		override protected function getCurrentSkinState():String
		{
			return super.getCurrentSkinState();
		} 
		
		override protected function partAdded(partName:String, instance:Object) : void
		{
			super.partAdded(partName, instance);
			
			if (instance == chatButton)
			{
				chatButton.addEventListener(MouseEvent.CLICK, handleChatButtonClick);
			}
		}
		
		public function handleChatButtonClick(e:MouseEvent):void
		{
			dispatchEvent(new GotoClickButtonEvent(GotoClickButtonEvent.GOTOCLICKBUTTONEVENT));
		}
		
		override protected function partRemoved(partName:String, instance:Object) : void
		{
			super.partRemoved(partName, instance);
		}
		
	}
}